#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;


int main()
{
	string  str;
	int n, flag = 1;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> str;
		flag = -1;
		for (auto& e : str)
		{
			if (e - '0' % 2 == 0)
			{
				swap(e, str[str.size()-1]);
				flag = 1;
				break;
			}
		}
		if (flag == 1)
		{
			cout << str << endl;
		}
		else
		{
			cout << -1 << endl;
		}
	}

	return 0;
}